/*
 * Copyright (c) 2025 Industrial Software Feature Database
 */
package com.comac.ins.isfd.constant.enums;

import com.comac.ins.common.core.utils.StringUtils;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 算子三级级分类枚举
 *
 * @author hxloongs
 * @date 2024-7-11
 */
@AllArgsConstructor
@Getter
public enum IsfdOperatorAlgorithmTypeEnum {
    WORK_STRESS("work_stress", "工作应力"),
    ADMISSIBLE_STRESS("admissible_stress", "许用应力"),
    MS("MS", "安全裕度"),
    WORK_LOAD("work_load", "工作载荷"),
    ADMISSIBLE_LOAD("admissible_load", "许用载荷"),
    WORK_STRAIN("work_strain", "工作应变"),
    ADMISSIBLE_STRAIN("admissible_strain", "许用应变"),
    STRESS_SPECTRUM("stress_spectrum", "应力载荷"),
    CFQ("cfq", "疲劳分析");
    private final String value;
    private final String desc;

    public static String getDescByValue(String value) {
        IsfdOperatorAlgorithmTypeEnum isfdOperatorAlgorithmTypeEnum = forValue(value);
        if (isfdOperatorAlgorithmTypeEnum == null) {
            return null;
        }
        return isfdOperatorAlgorithmTypeEnum.getDesc();
    }

    public static IsfdOperatorAlgorithmTypeEnum forValue(String value) {
        if (StringUtils.isBlank(value)) {
            return null;
        }
        for (IsfdOperatorAlgorithmTypeEnum isfdOperatorAlgorithmTypeEnum : IsfdOperatorAlgorithmTypeEnum.values()) {
            if (isfdOperatorAlgorithmTypeEnum.getValue().equals(value)) {
                return isfdOperatorAlgorithmTypeEnum;
            }
        }
        return null;
    }

    public static IsfdOperatorAlgorithmTypeEnum forDesc(String desc) {
        if (desc == null) {
            return null;
        }
        for (IsfdOperatorAlgorithmTypeEnum isfdOperatorAlgorithmTypeEnum : IsfdOperatorAlgorithmTypeEnum.values()) {
            if (desc.equals(isfdOperatorAlgorithmTypeEnum.getDesc())) {
                return isfdOperatorAlgorithmTypeEnum;
            }
        }
        return null;
    }
}
